import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getx_learn/app/common/widgets/widgets.dart';

import '../controllers/getx_controller_page_controller.dart';

class GetxControllerPageView extends GetView<GetxControllerPageController> {
  const GetxControllerPageView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar(context: context, title: "GetxController 生命周期"),
      body: ListView(
        children: [
          Text("页面退出时候，会调用 GetxControllerPageController#onClose 方法"),
          Text("""
          首次进入页面会执行:
          lifecyle = -----> onInit
          lifecyle = -----> onReady
          
          退出页面：
          lifecyle = -----> onClose
          """),
          Divider(),
          Divider(),
          Text("生命周期打印"),
          Divider(),
          Obx(
            () {
              return Text(controller.lifeStr.value);
            },
          )
        ],
      ),
    );
  }
}
